Component({
    properties: {
        ifShowText: {
            type: String,
            default: !0
        },
        listData: {
            type: Array,
            default: function() {
                return [];
            }
        },
        workingdate: {
            type: String,
            default: ""
        },
        firsttime: {
            type: String,
            default: ""
        },
        workingTimedate: {
            type: String,
            default: ""
        },
        btn: {
            type: String,
            default: ""
        },
        title: {
            type: String,
            default: ""
        },
        afterTodayTime: {
            type: Boolean,
            default: !1
        }
    },
    data: {
        showModalStatus: !1,
        canlendar: []
    },
    methods: {
        schedule: function() {
            for (var t = new Date(), a = t.getFullYear(), e = t.getMonth(), n = t.getDate(), i = new Date(this.formartDate(a, e + 1, n, "-")).getTime(), r = [], o = [], s = this.dateconsult(this.data.listData), d = 0; d < 4; d++) r[d] = this.total(d);
            for (var l = 0; l < 4; l++) {
                o.push({});
                var f, c, u = e + l + 1, h = a;
                u > 12 && (h += 1, u -= 12), f = new Date(h, u - 1, 0).getDate(), c = new Date(h, u - 1, 1).getDay(), 
                o[l].dataTitle = this.formartDate(h, u, "0", "ch"), o[l].datacontent = [];
                for (var g = 0; g < r[l]; g++) {
                    o[l].datacontent.push({});
                    var m = this.formartDate(h, u, g - c + 1, "-"), D = new Date(m).getTime(), w = this.isInArray(s, D);
                    if (0 == this.data.listData.length && this.data.afterTodayTime && (w = !0), 0 != this.data.listData.length || this.data.afterTodayTime || (w = !1), 
                    g < c) 0 == l ? (o[l].datacontent[g].text = "", o[l].datacontent[g].link = "", o[l].datacontent[g].time = f - c + g + 1, 
                    o[l].datacontent[g].flag = !1) : (o[l].datacontent[g].text = "", o[l].datacontent[g].link = "", 
                    o[l].datacontent[g].time = "", o[l].datacontent[g].flag = !1); else {
                        var p = D == i ? "今日" : "";
                        w ? (o[l].datacontent[g].text = p, o[l].datacontent[g].link = "", o[l].datacontent[g].time = g - c + 1, 
                        o[l].datacontent[g].flag = !0, D < i && 0 == s.length && (o[l].datacontent[g].flag = !1)) : (o[l].datacontent[g].text = p, 
                        o[l].datacontent[g].link = "", o[l].datacontent[g].time = g - c + 1, o[l].datacontent[g].flag = !1);
                    }
                }
            }
            this.setData({
                canlendar: o
            });
        },
        dateconsult: function(t) {
            for (var a = [], e = 0, n = 0; n < t.length; n++) e = new Date(t[n]).getTime(), 
            a[n] = e, e = 0;
            return a;
        },
        total: function(t) {
            var a = new Date(), e = a.getFullYear(), n = a.getMonth(), i = (a.getDate(), new Date(e, n + (t + 1), 0).getDate() + new Date(e, n + t, 1).getDay());
            return i;
        },
        isInArray: function(t, a) {
            if (t.indexOf && "function" == typeof t.indexOf && t.indexOf(a) >= 0) return !0;
            return !1;
        },
        formartDate: function(t, a, e, n) {
            switch (n) {
              case "ch":
                return t + "年" + (a = a.toString()[1] ? a : "0" + a) + "月";

              default:
                return t + (n = n) + (a = a.toString()[1] ? a : "0" + a) + n + (e = e.toString()[1] ? e : "0" + e);
            }
        },
        showTime: function(t) {
            var a = t.currentTarget.dataset, e = a.v, n = a.fv;
            if (e.flag) {
                var i = "";
                i = Number(e.time) < 10 ? "0" + String(e.time) : e.time;
                var r = n.split("年").join("-");
                r = r.split("月").join("-") + i, this.powerDrawer(), this.triggerEvent("atTime", r);
            }
        },
        emptyTime: function() {
            this.powerDrawer(), this.triggerEvent("atTime", !1);
        },
        powerDrawer: function() {
            var t = this.data.showModalStatus, a = wx.createAnimation({
                duration: 200,
                timingFunction: "linear",
                delay: 0
            });
            this.animation = a, a.translateY(500).step(), this.setData({
                animationData: a.export()
            }), setTimeout(function() {
                a.translateY(0).step(), this.setData({
                    animationData: a
                }), t && this.setData({
                    showModalStatus: !1
                });
            }.bind(this), 100), t || this.setData({
                showModalStatus: !0
            });
        }
    },
    lifetimes: {
        attached: function() {
            this.schedule();
        }
    }
});